extends BaseDlg


var townNum = 0
var dilaoNum = 0
onready var townNumLabel = $OptBtns/VBoxContainer/chaNum/townNum
onready var dilaoNumLabel = $OptBtns/VBoxContainer/chaNum/dilaoNum

func upTown():
	townNumLabel.bbcode_text = "城镇：%d/12" % [townNum]

func upDilao():
	dilaoNumLabel.bbcode_text = "地牢：%d/12" % [dilaoNum]

func _on_baseDlg_onDel():
	data.saveLock()

func closeCheck():
	if checkban() or not sys.main.ui.has_node("bookDlg"):
		del()
	else:
		sys.newMsg("启用人数不够！")
		return

func checkban():
	if townNum < 12 or dilaoNum < 12:
		return false
	return true

func _ready():
	data.connect("onSetCry",self,"_setCry")
	_setCry()
	sys.addTip($Button,"禁用本页可解锁的内容，使他们不会出现在游戏里") 
	
	if not sys.has_node("VEBase"):
		var base = load(data.infoDs["VEBase"]["VEBase"].dir).new()
		base.name = "VEBase"
		sys.add_child(base)
	
	var btn = get_node("bg/closeBtn")
	btn.disconnect("pressed",self,"_on_closeBtn_pressed")
	btn.connect("pressed",self,"closeCheck")

func _setCry():
	$NinePatchRect/Label.text = "%d" % data.cry
	sys.addTip($NinePatchRect/TextureRect,"解锁部分内容所消耗的晶石")

func _on_Button_pressed():
	sys.newMsg("已禁用本页解锁的内容")
	$TabContainer.get_current_tab_control().SetAllDisable(true)
